#include <iostream>
#include <unistd.h>
#include <string.h>
#include "ShareMenory.hpp"
#include "Fifo.hpp"
#include "Time.hpp"

int main()las
{
    std::cout << "time: " << GetCurrTime() << std::endl;
    std::cout << "self pid: " << getpid() << std::endl; //获取当前进程的id
    shm.CreateShm(); //创建共享内存
    shm.AttchShm(); //挂载到虚拟地址空间

    gpipe.OpenPipeForRead();
    //在这里进行ipc通信
    struct data *image = (struct data *)shm.GetAddr();

    //从共享内存读取, 利用管道进行消息同步
    while(true)
    {
        gpipe.Wait(); //等待写管道传递信号, 继续执行下面代码
        printf("status: %s\n", image->status);
        printf("lasttime: %s\n", image->lasttime);
        printf("image: %s\n", image->image);
        strcpy(image->status, "过期");
    }
    
    shm.DetachShm(); //移除挂载
    shm.DeleteShm(); //删除共享内存
    return 0;
}